constant N1, N2, N3;

for (i = 1; i < N1 - 1; i++) {
  for (j = 1; j < N2 - 1; j++) {
    for (k = 1; k < N3 - 1; k++) {
      A[i][j][k] =
          (A[i][j][k] +
           B[0] * (A[i][j][k + 1] + A[i][j][k - 1] + A[i][j + 1][k] +
                   A[i][j - 1][k] + A[i + 1][j][k] + A[i - 1][j][k]) +
           B[1] *
               (A[i][j + 1][k + 1] + A[i][j + 1][k - 1] + A[i + 1][j][k + 1] +
                A[i + 1][j][k - 1] + A[i][j - 1][k + 1] + A[i][j - 1][k - 1] +
                A[i - 1][j][k + 1] + A[i - 1][j][k - 1] + A[i + 1][j + 1][k] +
                A[i + 1][j - 1][k] + A[i - 1][j + 1][k] + A[i - 1][j - 1][k])) *
          0.50;
    }
  }
}
